;;;place sewer tap on a single run.
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
;;;	Copyright:  6-1-2001
;;;	   Edited:  6-1-2001
(defun c:stap ()
  (setq mysel (nentselp "\nSelect line (pick near starting end)"))
  (setq myent (entget (car mysel)))
  (if (eq (cdr (assoc 0 myent)) "LINE")
    (progn
      (setq mhrad (ureal 1 "" "Manhole radius" (if mhrad mhrad 5.0)))
      (if (<
	    (distance
	      (reverse (cdr(reverse(cdr(assoc 10 myent)))))
              (cadr mysel)
	    )
	    (distance
	      (reverse (cdr(reverse(cdr(assoc 11 myent)))))
              (cadr mysel)
	    )
	  )
	  (setq linang (angle (reverse (cdr(reverse(cdr(assoc 10 myent)))))
			      (reverse (cdr(reverse(cdr(assoc 11 myent))))))
		strtpt (polar (cdr(assoc 10 myent)) (+ linang pi) mhrad)
          )
	  (setq linang (angle (reverse (cdr(reverse(cdr(assoc 11 myent)))))
			      (reverse (cdr(reverse(cdr(assoc 10 myent))))))
		strtpt (polar (cdr(assoc 11 myent)) (+ linang pi) mhrad)
	  )
      )
      (setq stlen (ureal 1 "Default" "Stated line length <or Default>" (if stlen stlen "Default")))
      (setq actlen (distance
		     (reverse (cdr(reverse(cdr(assoc 10 myent)))))
		     (reverse (cdr(reverse(cdr(assoc 11 myent)))))
		   )
      )
      (if (eq stlen "Default") (setq stlen actlen))
      (setq stafac (/ actlen stlen))
      (setq taplen (ureal 1 "" "Length of taps" (if taplen taplen nil)))
      (while
	(setq tapsta (ureal 0 "" "Tap station" nil))
	(setq actapsta (* tapsta stafac))
	(setq tapside (ukword 1 "Left Right" "Side for tap <Left Right>" (if tapside tapside "")))
	(setq tapang (if (eq tapside "Left") (+ linang (/ pi 2.0))(- linang (/ pi 2.0))))
	(setq tapt1 (polar strtpt linang actapsta))
	(setq tapt2 (polar tapt1 tapang taplen))
	(command ".line" tapt1 tapt2 "")
      )
    )
  )
)